using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder;
using Microsoft.Practices.EnterpriseLibrary.Data.Instrumentation;


namespace Model
{
	/// <summary>
	/// Summary description for SqlHelper.
	/// </summary>
	public class SqlHelper
	{
        private static string ConnectionString()
        {
            return ConfigurationSettings.AppSettings["ConnectionString"];
        }


		public static int ExecuteNonQuery( string spName, params object [] parameterValues )
		{
            SqlDatabase db = new SqlDatabase(ConnectionString());
			return db.ExecuteNonQuery( spName, parameterValues);
		}

		public static SqlDataReader ExecuteReader( string spName, params object [] parameterValues )
		{
            SqlDatabase db = new SqlDatabase(ConnectionString());
            return (SqlDataReader)db.ExecuteReader(spName, parameterValues);
        }

        public static SqlDataReader ExecuteReader(string StrComando)
        {
            SqlDatabase db = new SqlDatabase(ConnectionString());
            return (SqlDataReader)db.ExecuteReader(CommandType.Text, StrComando);
        }

        public static DataTable ExecuteDataTable(string strComando)
        {
            SqlDatabase db = new SqlDatabase(ConnectionString());
            return db.ExecuteDataSet(CommandType.Text,strComando).Tables[0];

        }

        public static DataTable ExecuteDataTable(string spName, params object[] parameterValues)
        {
            SqlDatabase db = new SqlDatabase(ConnectionString());
            return db.ExecuteDataSet(spName, parameterValues).Tables[0];
        }

        public static int ExecuteNonQuery(string strComando)
        {
            SqlDatabase db = new SqlDatabase(ConnectionString());
            return db.ExecuteNonQuery(CommandType.Text , strComando);
        }


    }
}
